package com.itheima.d2_byte_stream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/*
     目标：使用字节流完成对文件的复制操作。
     数据源
     目的地
 */
public class CopyTest5 {
    public static void main(String[] args) throws Exception {
        long start = System.currentTimeMillis();
        copy2();
        long end = System.currentTimeMillis();
        System.out.println("打印时间为" + (end - start));
    }

    //23
    public static void copy2() throws Exception {
        FileInputStream fis = new FileInputStream("D:\\AAA\\壁纸\\wallhaven\\wallhaven-m3zx3m_1920x1080.png");
        FileOutputStream fos = new FileOutputStream("B.png");

        byte[] bytes = new byte[1024];
        int byt;
        while ((byt = fis.read(bytes)) != -1) {
            fos.write(bytes, 0, byt);
        }
        fis.close();
        fos.close();

    }

    //16656
    public static void copy1() throws Exception {
        FileInputStream fis = new FileInputStream("D:\\AAA\\壁纸\\wallhaven\\wallhaven-m3zx3m_1920x1080.png");
        FileOutputStream fos = new FileOutputStream("a.png");

        int byt;
        while ((byt = fis.read()) != -1) {
            fos.write(byt);
        }
        fis.close();
        fos.close();
    }

}
